using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BB.Processes.Models.Mapping
{
    public class JogoMap : EntityTypeConfiguration<Jogo>
    {
        public JogoMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("Jogoes");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.HomeTeam).HasColumnName("HomeTeam");
            this.Property(t => t.AwayTeam).HasColumnName("AwayTeam");
            this.Property(t => t.HomeScore).HasColumnName("HomeScore");
            this.Property(t => t.AwayScore).HasColumnName("AwayScore");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.Fulfilled).HasColumnName("Fulfilled");
            this.Property(t => t.CompeticaoId).HasColumnName("CompeticaoId");
            this.Property(t => t.JornadaId).HasColumnName("JornadaId");

            // Relationships
            this.HasOptional(t => t.Competicao)
                .WithMany(t => t.Jogoes)
                .HasForeignKey(d => d.CompeticaoId);
            this.HasOptional(t => t.Jornada)
                .WithMany(t => t.Jogoes)
                .HasForeignKey(d => d.JornadaId);

        }
    }
}
